home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / nb30.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  12.6 KB  |  320 lines

  1. //*++
  2. //
  3. // Copyright (c) 1991-1996  Microsoft Corporation
  4. //
  5. // Module Name:
  6. //
  7. //  nb30.h
  8. //
  9. // Abstract:
  10. //
  11. //  This module contains the definitions for portable NetBIOS 3.0
  12. //  support.
  13. //
  14. //--*/
  15.  
  16. #ifndef NCB_INCLUDED
  17. #define NCB_INCLUDED
  18. #pragma option push -b
  19.  
  20.  
  21. #if defined (__BORLANDC__)
  22. #  include <pshpack8.h>
  23. #endif
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29. /****************************************************************
  30.  *                                                              *
  31.  *              Data structure templates                        *
  32.  *                                                              *
  33.  ****************************************************************/
  34.  
  35. #define NCBNAMSZ        16    /* absolute length of a net name           */
  36. #define MAX_LANA       254    /* lana's in range 0 to MAX_LANA inclusive */
  37.  
  38. /*
  39.  * Network Control Block
  40.  */
  41.  
  42. typedef struct _NCB {
  43.     UCHAR   ncb_command;            /* command code                   */
  44.     UCHAR   ncb_retcode;            /* return code                    */
  45.     UCHAR   ncb_lsn;                /* local session number           */
  46.     UCHAR   ncb_num;                /* number of our network name     */
  47.     PUCHAR  ncb_buffer;             /* address of message buffer      */
  48.     WORD    ncb_length;             /* size of message buffer         */
  49.     UCHAR   ncb_callname[NCBNAMSZ]; /* blank-padded name of remote    */
  50.     UCHAR   ncb_name[NCBNAMSZ];     /* our blank-padded netname       */
  51.     UCHAR   ncb_rto;                /* rcv timeout/retry count        */
  52.     UCHAR   ncb_sto;                /* send timeout/sys timeout       */
  53.     void (CALLBACK *ncb_post)( struct _NCB * ); /* POST routine address        */
  54.     UCHAR   ncb_lana_num;           /* lana (adapter) number          */
  55.     UCHAR   ncb_cmd_cplt;           /* 0xff => commmand pending       */
  56.     UCHAR   ncb_reserve[10];        /* reserved, used by BIOS         */
  57.     HANDLE  ncb_event;              /* HANDLE to Win32 event which    */
  58.                                     /* will be set to the signalled   */
  59.                                     /* state when an ASYNCH command   */
  60.                                     /* completes                      */
  61. } NCB, *PNCB;
  62.  
  63. /*
  64.  *  Structure returned to the NCB command NCBASTAT is ADAPTER_STATUS followed
  65.  *  by an array of NAME_BUFFER structures.
  66.  */
  67.  
  68. typedef struct _ADAPTER_STATUS {
  69.     UCHAR   adapter_address[6];
  70.     UCHAR   rev_major;
  71.     UCHAR   reserved0;
  72.     UCHAR   adapter_type;
  73.     UCHAR   rev_minor;
  74.     WORD    duration;
  75.     WORD    frmr_recv;
  76.     WORD    frmr_xmit;
  77.  
  78.     WORD    iframe_recv_err;
  79.  
  80.     WORD    xmit_aborts;
  81.     DWORD   xmit_success;
  82.     DWORD   recv_success;
  83.  
  84.     WORD    iframe_xmit_err;
  85.  
  86.     WORD    recv_buff_unavail;
  87.     WORD    t1_timeouts;
  88.     WORD    ti_timeouts;
  89.     DWORD   reserved1;
  90.     WORD    free_ncbs;
  91.     WORD    max_cfg_ncbs;
  92.     WORD    max_ncbs;
  93.     WORD    xmit_buf_unavail;
  94.     WORD    max_dgram_size;
  95.     WORD    pending_sess;
  96.     WORD    max_cfg_sess;
  97.     WORD    max_sess;
  98.     WORD    max_sess_pkt_size;
  99.     WORD    name_count;
  100. } ADAPTER_STATUS, *PADAPTER_STATUS;
  101.  
  102. typedef struct _NAME_BUFFER {
  103.     UCHAR   name[NCBNAMSZ];
  104.     UCHAR   name_num;
  105.     UCHAR   name_flags;
  106. } NAME_BUFFER, *PNAME_BUFFER;
  107.  
  108. //  values for name_flags bits.
  109.  
  110. #define NAME_FLAGS_MASK 0x87
  111.  
  112. #define GROUP_NAME      0x80
  113. #define UNIQUE_NAME     0x00
  114.  
  115. #define REGISTERING     0x00
  116. #define REGISTERED      0x04
  117. #define DEREGISTERED    0x05
  118. #define DUPLICATE       0x06
  119. #define DUPLICATE_DEREG 0x07
  120.  
  121. /*
  122.  *  Structure returned to the NCB command NCBSSTAT is SESSION_HEADER followed
  123.  *  by an array of SESSION_BUFFER structures. If the NCB_NAME starts with an
  124.  *  asterisk then an array of these structures is returned containing the
  125.  *  status for all names.
  126.  */
  127.  
  128. typedef struct _SESSION_HEADER {
  129.     UCHAR   sess_name;
  130.     UCHAR   num_sess;
  131.     UCHAR   rcv_dg_outstanding;
  132.     UCHAR   rcv_any_outstanding;
  133. } SESSION_HEADER, *PSESSION_HEADER;
  134.  
  135. typedef struct _SESSION_BUFFER {
  136.     UCHAR   lsn;
  137.     UCHAR   state;
  138.     UCHAR   local_name[NCBNAMSZ];
  139.     UCHAR   remote_name[NCBNAMSZ];
  140.     UCHAR   rcvs_outstanding;
  141.     UCHAR   sends_outstanding;
  142. } SESSION_BUFFER, *PSESSION_BUFFER;
  143.  
  144. //  Values for state
  145.  
  146. #define LISTEN_OUTSTANDING      0x01
  147. #define CALL_PENDING            0x02
  148. #define SESSION_ESTABLISHED     0x03
  149. #define HANGUP_PENDING          0x04
  150. #define HANGUP_COMPLETE         0x05
  151. #define SESSION_ABORTED         0x06
  152.  
  153. /*
  154.  *  Structure returned to the NCB command NCBENUM.
  155.  *
  156.  *  On a system containing lana's 0, 2 and 3, a structure with
  157.  *  length =3, lana[0]=0, lana[1]=2 and lana[2]=3 will be returned.
  158.  */
  159.  
  160. typedef struct _LANA_ENUM {
  161.     UCHAR   length;         //  Number of valid entries in lana[]
  162.     UCHAR   lana[MAX_LANA+1];
  163. } LANA_ENUM, *PLANA_ENUM;
  164.  
  165. /*
  166.  *  Structure returned to the NCB command NCBFINDNAME is FIND_NAME_HEADER followed
  167.  *  by an array of FIND_NAME_BUFFER structures.
  168.  */
  169.  
  170. typedef struct _FIND_NAME_HEADER {
  171.     WORD    node_count;
  172.     UCHAR   reserved;
  173.     UCHAR   unique_group;
  174. } FIND_NAME_HEADER, *PFIND_NAME_HEADER;
  175.  
  176. typedef struct _FIND_NAME_BUFFER {
  177.     UCHAR   length;
  178.     UCHAR   access_control;
  179.     UCHAR   frame_control;
  180.     UCHAR   destination_addr[6];
  181.     UCHAR   source_addr[6];
  182.     UCHAR   routing_info[18];
  183. } FIND_NAME_BUFFER, *PFIND_NAME_BUFFER;
  184.  
  185. /*
  186.  *  Structure provided with NCBACTION. The purpose of NCBACTION is to provide
  187.  *  transport specific extensions to netbios.
  188.  */
  189.  
  190. typedef struct _ACTION_HEADER {
  191.     ULONG   transport_id;
  192.     USHORT  action_code;
  193.     USHORT  reserved;
  194. } ACTION_HEADER, *PACTION_HEADER;
  195.  
  196. //  Values for transport_id
  197.  
  198. #define ALL_TRANSPORTS  "M\0\0\0"
  199. #define MS_NBF          "MNBF"
  200.  
  201.  
  202. /****************************************************************
  203.  *                                                              *
  204.  *              Special values and constants                    *
  205.  *                                                              *
  206.  ****************************************************************/
  207.  
  208. /*
  209.  *      NCB Command codes
  210.  */
  211.  
  212. #define NCBCALL         0x10            /* NCB CALL                           */
  213. #define NCBLISTEN       0x11            /* NCB LISTEN                         */
  214. #define NCBHANGUP       0x12            /* NCB HANG UP                        */
  215. #define NCBSEND         0x14            /* NCB SEND                           */
  216. #define NCBRECV         0x15            /* NCB RECEIVE                        */
  217. #define NCBRECVANY      0x16            /* NCB RECEIVE ANY                    */
  218. #define NCBCHAINSEND    0x17            /* NCB CHAIN SEND                     */
  219. #define NCBDGSEND       0x20            /* NCB SEND DATAGRAM                  */
  220. #define NCBDGRECV       0x21            /* NCB RECEIVE DATAGRAM               */
  221. #define NCBDGSENDBC     0x22            /* NCB SEND BROADCAST DATAGRAM        */
  222. #define NCBDGRECVBC     0x23            /* NCB RECEIVE BROADCAST DATAGRAM     */
  223. #define NCBADDNAME      0x30            /* NCB ADD NAME                       */
  224. #define NCBDELNAME      0x31            /* NCB DELETE NAME                    */
  225. #define NCBRESET        0x32            /* NCB RESET                          */
  226. #define NCBASTAT        0x33            /* NCB ADAPTER STATUS                 */
  227. #define NCBSSTAT        0x34            /* NCB SESSION STATUS                 */
  228. #define NCBCANCEL       0x35            /* NCB CANCEL                         */
  229. #define NCBADDGRNAME    0x36            /* NCB ADD GROUP NAME                 */
  230. #define NCBENUM         0x37            /* NCB ENUMERATE LANA NUMBERS         */
  231. #define NCBUNLINK       0x70            /* NCB UNLINK                         */
  232. #define NCBSENDNA       0x71            /* NCB SEND NO ACK                    */
  233. #define NCBCHAINSENDNA  0x72            /* NCB CHAIN SEND NO ACK              */
  234. #define NCBLANSTALERT   0x73            /* NCB LAN STATUS ALERT               */
  235. #define NCBACTION       0x77            /* NCB ACTION                         */
  236. #define NCBFINDNAME     0x78            /* NCB FIND NAME                      */
  237. #define NCBTRACE        0x79            /* NCB TRACE                          */
  238.  
  239.  
  240. #define ASYNCH          0x80            /* high bit set == asynchronous       */
  241.  
  242. /*
  243.  *      NCB Return codes
  244.  */
  245.  
  246. #define NRC_GOODRET     0x00    /* good return                                */
  247.                                 /* also returned when ASYNCH request accepted */
  248. #define NRC_BUFLEN      0x01    /* illegal buffer length                      */
  249. #define NRC_ILLCMD      0x03    /* illegal command                            */
  250. #define NRC_CMDTMO      0x05    /* command timed out                          */
  251. #define NRC_INCOMP      0x06    /* message incomplete, issue another command  */
  252. #define NRC_BADDR       0x07    /* illegal buffer address                     */
  253. #define NRC_SNUMOUT     0x08    /* session number out of range                */
  254. #define NRC_NORES       0x09    /* no resource available                      */
  255. #define NRC_SCLOSED     0x0a    /* session closed                             */
  256. #define NRC_CMDCAN      0x0b    /* command cancelled                          */
  257. #define NRC_DUPNAME     0x0d    /* duplicate name                             */
  258. #define NRC_NAMTFUL     0x0e    /* name table full                            */
  259. #define NRC_ACTSES      0x0f    /* no deletions, name has active sessions     */
  260. #define NRC_LOCTFUL     0x11    /* local session table full                   */
  261. #define NRC_REMTFUL     0x12    /* remote session table full                  */
  262. #define NRC_ILLNN       0x13    /* illegal name number                        */
  263. #define NRC_NOCALL      0x14    /* no callname                                */
  264. #define NRC_NOWILD      0x15    /* cannot put * in NCB_NAME                   */
  265. #define NRC_INUSE       0x16    /* name in use on remote adapter              */
  266. #define NRC_NAMERR      0x17    /* name deleted                               */
  267. #define NRC_SABORT      0x18    /* session ended abnormally                   */
  268. #define NRC_NAMCONF     0x19    /* name conflict detected                     */
  269. #define NRC_IFBUSY      0x21    /* interface busy, IRET before retrying       */
  270. #define NRC_TOOMANY     0x22    /* too many commands outstanding, retry later */
  271. #define NRC_BRIDGE      0x23    /* ncb_lana_num field invalid                 */
  272. #define NRC_CANOCCR     0x24    /* command completed while cancel occurring   */
  273. #define NRC_CANCEL      0x26    /* command not valid to cancel                */
  274. #define NRC_DUPENV      0x30    /* name defined by anther local process       */
  275. #define NRC_ENVNOTDEF   0x34    /* environment undefined. RESET required      */
  276. #define NRC_OSRESNOTAV  0x35    /* required OS resources exhausted            */
  277. #define NRC_MAXAPPS     0x36    /* max number of applications exceeded        */
  278. #define NRC_NOSAPS      0x37    /* no saps available for netbios              */
  279. #define NRC_NORESOURCES 0x38    /* requested resources are not available      */
  280. #define NRC_INVADDRESS  0x39    /* invalid ncb address or length > segment    */
  281. #define NRC_INVDDID     0x3B    /* invalid NCB DDID                           */
  282. #define NRC_LOCKFAIL    0x3C    /* lock of user area failed                   */
  283. #define NRC_OPENERR     0x3f    /* NETBIOS not loaded                         */
  284. #define NRC_SYSTEM      0x40    /* system error                               */
  285.  
  286. #define NRC_PENDING     0xff    /* asynchronous command is not yet finished   */
  287.  
  288. /****************************************************************
  289.  *                                                              *
  290.  *              main user entry point for NetBIOS 3.0           *
  291.  *                                                              *
  292.  * Usage: result = Netbios( pncb );                             *
  293.  ****************************************************************/
  294.  
  295. UCHAR
  296. APIENTRY
  297. Netbios(
  298.     PNCB pncb
  299.     );
  300.  
  301. /****************************************************************
  302.  *                                                              *
  303.  *              Prefix for callback routines                    *
  304.  *                                                              *
  305.  * Usage in a declaration: NCB_POST MyPostRoutine( PNCB pncb ); *
  306.  ****************************************************************/
  307.  
  308. #define NCB_POST void CALLBACK
  309.  
  310. #ifdef __cplusplus
  311. }
  312. #endif
  313.  
  314. #if defined (__BORLANDC__)
  315. #  include <poppack.h>
  316. #endif
  317.  
  318. #pragma option pop
  319. #endif /* NCB_INCLUDED */
  320.